﻿using HRIS.Browser.UI.ConfigReader;
using Iit.Automation.Browsers.Shared;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HRISEnums = HRIS.Browser.UI.Framework.HRISEnums;
using IITEnums = Iit.Automation.Browsers.Shared.IitEnums;

namespace HRIS.Browser.UI.Framework.DesktopWebControls
{
    public class Login : LoginBase<RemoteWebElement>, IConfigurableComponent
    {
        private IBrowser _browser;

        public void ConfigureMe(IBrowser browser, IITEnums.Environment env)
        {
            ConfigProvider config = ConfigProvider.GetInstance();

            _browser = browser;
            Element = (RemoteWebElement)browser.FindElement(config.Login.Element);
            txtPassword = (RemoteWebElement)Element.FindElement(config.Login.txtPassword);
            txtUserId = (RemoteWebElement)Element.FindElement(config.Login.txtUserId);
            btnLogin = (RemoteWebElement)Element.FindElement(config.Login.btnLogin);
        }

        public void DoLogin(string user, string password)
        {
            txtUserId.SendKeys(user);
            txtPassword.SendKeys(password);
            btnLogin.Click();
        }
    }
}
